// pages/wode/about/about.js
let app = getApp()
let yuming = app.globalData.yuming
const request = require('../../config/request');
Page({
  /**
   * 页面的初始数据
   */
  ...request,
  data: {
    heights: '',
    titles: "协议",
    id: '', //1服务2帮助3关于我们4登录
    xq: [],
    content: [],
    shenfen: '', //1会计2企业
    state: '',
    st:''
  },
  backs() {
    wx.navigateBack({
      delta: 1
    })
  },
  xq() {
    var that = this
    wx.showLoading({
      title: '加载中',
      icon: 'none'
    })
    this.myRequest(yuming + 'Besall/thatHomeAgreement', {
      place: that.data.state
    }, 'POST').then(res => {
      wx.hideLoading();
      that.setData({
        xq: res.data.data,
        content: res.data.data.content.replace(/(\<img|\<p)/gi, function ($0, $1) {
          return {
            "<img": '<img style="width:100%;height:auto;display:block;" ',
            "<p": '<p style="text-indent: 2em;" ',
            "<article": "<div",
            "</article": "</div",
            "<header": "<div",
            "</header": "</div"
          } [$1];
        })
      })
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    this.setData({
      heights: wx.getMenuButtonBoundingClientRect().top + 5,
      titles: options.title,
      id: options.id,
      shenfen: options.shenfen,
      state: options.state,
      st:options.st
    })
    // if(this.data.st==0){
      this.xq()
    // }
    // if(this.data.st==1){
      this.info()
    // }
  },
  info(){
    this.myRequest(yuming + 'Besall/findShopInfos', {
      shopId:wx.getStorageSync('shopId')
    }, 'POST').then(res => {
      wx.hideLoading();
      this.setData({
        infos:res.data.data.apikey
      })
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },
})